<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include/head::commonHeaderList('activityInfo')">
    <!--<body oncontextmenu="self.event.returnValue=false" onselectstart="return false">-->
<!--<link rel="stylesheet"  th:href="@{/static/css/}" />-->
<body>
<div id="content" class="col-lg-12 col-sm-12">
    <div class="row">
        <div class="box col-md-12">
            <div class="box-inner">
                <div class="box-header well" data-original-title="">
                    <h2>
                        <i class="glyphicon glyphicon-user"></i> activityInfo
                    </h2>
                    <div class="box-icon">
                        <!-- <a href="#" class="btn btn-setting btn-round btn-default"><i class="glyphicon glyphicon-cog"></i></a> -->
                        <a href="javascript:void(0);" id="smaller" class="btn btn-minimize btn-round btn-default"><i class="glyphicon glyphicon-chevron-up"></i></a>
                        <!-- <a href="#"	class="btn btn-close btn-round btn-default"><i class="glyphicon glyphicon-remove"></i></a> -->
                    </div>
                </div>
                <div class="box-content">
                    <form class="form-inline" style="margin-bottom:0.5%" id="searchForm" role="form" method="post"
                          th:action="${#request.getRequestURI()}">
                            <div class="form-group ">
                                <select name="pageSize"  class="form-control input-sm" >
                                    <option value="10" th:selected="${pageSize==10}">10条/页</option>
                                    <option value="25" th:selected="${pageSize==25}">25条/页</option>
                                    <option value="50" th:selected="${pageSize==50}">50条/页</option>
                                </select>
                            </div>

                        <div class="form-group">
                            <select name="state" id="state" class="input-sm">
                                <option value="">--选择活动状态--</option>
                                <option value="1" th:selected="${state == '1'}">正常</option>
                                <option value="0" th:selected="${state == '0'}">已删除</option>
                            </select>
							<input type="searchKey" name="searchKey" th:value="${searchKey}" id="search" class="form-control input-sm" style="width:200px;" placeholder="请输入关键词" autocomplete="off">
							<button class="btn btn-info btn-sm" type="submit"> 查 询 </button>
                            <a id="add" th:if="${session.menuMap[278] != null and session.menuMap['278'] !=''}" href="javascript:void(0)" onclick="addActivityInfo()" class="btn btn-primary btn-sm "><span class="glyphicon glyphicon-plus-sign"></span> 添 加 </a>
                        </div>
                        <div class="form-group" style="display: none">
                                <div class="input-group input-group-sm">
                                    <input type="hidden" th:value="${pageInfo.pageNum}" name="pageNum" id="pageNum">
                                </div>
						</div>

                    </form>
                    <table class="table table-striped table-bordered table-hover footable" data-show-toggle="false">
                        <thead>
							<tr>
								<th style="text-align: center;" data-breakpoints="xs">活动名称</th>
								<th style="text-align: center;white-space:nowrap;">绑定套餐</th>
								<th style="text-align: center;white-space:nowrap;">开始时间</th>
								<th style="text-align: center;white-space:nowrap;">结束时间</th>
								<th style="text-align: center;white-space:nowrap;">创建时间</th>
								<th style="text-align: center;white-space:nowrap;">创建人</th>
								<th style="text-align: center;white-space:nowrap;">状态</th>
								<th style="text-align: center;white-space:nowrap;" data-breakpoints="xs">操作</th>
							</tr>
                        </thead>
                        <tbody>
							 <tr th:each="list,listStat: ${pageInfo.list}">
							    <td style="text-align: center;" th:text="${list.activityName}"> </td>
								<td style="text-align: center;" th:text="${list.packageName}"> </td>
								<td style="text-align: center;" th:text="${#dates.format(list.startTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
								<td style="text-align: center;" th:text="${#dates.format(list.endTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
								<td style="text-align: center;" th:text="${#dates.format(list.addTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
								<td style="text-align: center;" th:text="${list.addUser}"> </td>
								<td style="text-align: center;" th:if="${list.state == '1'}"> 正常</td>
								<td style="text-align: center;" th:if="${list.state == '0'}"> 已删除</td>
								<td style="text-align: left;">
									 <a th:if="${session.menuMap[280] != null and session.menuMap['280'] !=''}" th:attr="data-id=${list.id}"  onclick="editeActivityInfo(this)"  class="btn btn-primary eidt btn-sm"><span class="glyphicon glyphicon-edit"></span> 编 辑 </a>
									 <a th:if="${session.menuMap[279] != null and session.menuMap['279'] !=''}" th:attr="data-id=${list.id}"  onclick="delActivityInfo(this)"  class="btn btn-danger opblock-delete btn-sm"><span class="glyphicon glyphicon-remove"></span> 删 除 </a>
									 <a th:attr="data-id=${list.id}"  onclick="lookupActivityInfo(this)"  class="btn btn-danger opblock-delete btn-sm"><span class="glyphicon glyphicon-share"></span> 查 看 </a>
								</td>
							 </tr>
                        </tbody>
                    </table>
                    <div th:include="include/pageinfo::pager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include/onload_js::onloadJSCustomList(~{::script})">
    <script>
		$(function(){
		     //自适应表格
            $('.footable').footable();
		});
	//layer  学员成绩相关信息 添加页面弹窗
	function addActivityInfo(){
		var url = "/activityInfoCtl/toAddActivityInfo";
		layer.open({
			type: 2,
			title: false,
			closeBtn: 1, //显示关闭按钮
			shade: [0],
			area: ['700px', '600px'], //宽高
			//offset: 'rb', //右下角弹出
			// time: 2000, //2秒后自动关闭
			anim: 2,
			content: [url, 'no'], //iframe的url，no代表不显示滚动条
			end: function () { //此处用于演示
			}
		});
	}

	//layer  学员成绩相关信息 编辑页面弹窗
	function editeActivityInfo(obj){
		var url = "/activityInfoCtl/toEidtActivityInfo?id="+$(obj).attr("data-id");
		layer.open({
			type: 2,
			title: false,
			closeBtn: 1, //显示关闭按钮
			shade: [0],
			area: ['700px', '600px'], //宽高
			//offset: 'rb', //右下角弹出
			// time: 2000, //2秒后自动关闭
			anim: 2,
			content: [url, 'no'], //iframe的url，no代表不显示滚动条
			end: function () { //此处用于演示
			}
		});
	}

		//layer  学员成绩相关信息 编辑页面弹窗
	function lookupActivityInfo(obj){
		var url = "/activityInfoCtl/toLookupActivityInfo?id="+$(obj).attr("data-id");
		layer.open({
			type: 2,
			title: false,
			closeBtn: 1, //显示关闭按钮
			shade: [0],
			area: ['700px', '600px'], //宽高
			//offset: 'rb', //右下角弹出
			// time: 2000, //2秒后自动关闭
			anim: 2,
			content: [url, 'no'], //iframe的url，no代表不显示滚动条
			end: function () { //此处用于演示
			}
		});
	}

	function delActivityInfo (obj){
	    var id = $(obj).attr("data-id")
	    layer.confirm('是否确认删除?', {
          btn: ['是','否'] //按钮
          ,cancel: function(index, layero){
            //取消操作，点击右上角的X
          }
        }, function(){
            $.ajax({
                type:'post',
                url:'/activityInfoCtl/delActivityInfo',
                data:{'id' : id},
                cache:false,
                async: false,
                dataType:'json',
                success:function(data){
                    if(data.code>0){
                        layer.msg("删除成功",{icon: 1});
                        setTimeout(function() {
                            window.location.reload();
                        },2500)
                    }else{
                        layer.msg("删除失败",{icon: 2});
                    }
                }
            });
        }, function(){
        //否
        });
	}
    </script>
</div>
</body>
</html>
